import Vue from 'vue'
import Vuex from 'vuex'

// 1引入持久化插件
import vuexPersistedstate from "vuex-persistedstate";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:{},
    username:'',
  },
  getters: {
  },
  mutations: {
    //传的是对象
    //存储对象
    storeUser(state,v){
      state.user=v;//对象
      state.username=v.username
    },
    //删除对象
    clearAwayUser(state){
      //设置为空
      state.user={};
      state.username='';
    }
  },
  actions: {
  },
  modules: {
  },
  plugins:[vuexPersistedstate()] // 2加入插件
})
